package ppjava12v1.chess.entities.users;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Профиль пользователя
 *
 * Хранит
 *  - Реальное имя
 *  - количество побед
 *  - количество поражений
 *  - количество ничьих
 */
@Entity
@Table(name = "usr_profile")
public class UserProfile implements Serializable {

    @OneToOne(targetEntity = User.class)
    @JoinColumn(name = "user_id")
    @Id
    private User user;

    @Column(length = 32)
    private String realName;

    @Column(length = 32, nullable = false, name = "nickname", unique = true)
    private String nickName;

    @Column
    private int wins;

    @Column
    private int defeats;

    @Column
    private int draws;


    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public int getWins() {
        return wins;
    }

    public void setWins(int wins) {
        this.wins = wins;
    }

    public int getDefeats() {
        return defeats;
    }

    public void setDefeats(int defeats) {
        this.defeats = defeats;
    }

    public int getDraws() {
        return draws;
    }

    public void setDraws(int draws) {
        this.draws = draws;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Override
    public String toString() {
        return  "realName='" + realName + '\'' +
                ", nickName='" + nickName + '\'' +
                ", wins=" + wins +
                ", defeats=" + defeats +
                ", draws=" + draws;
    }

}
